<?php
require 'conn.php';
$partner=@$_GET["partner"];
$out_trade_no=@$_GET["out_trade_no"];
$notify_id=@$_GET["notify_id"];

//$str=$partner."&".$out_trade_no."&".$notify_id;

//file_put_contents('log.txt',$str,FILE_APPEND);

//判断是否有这个合作者
getconn();
$sql="select * from account  where partner='".$partner."'";
$result=mysql_query($sql);
$i=mysql_num_rows($result);

if ($i<=0){
	echo "false";
	exit();
}

//判断该次通知时间是否超出1分钟
$notify_id=intval($notify_id);
$nowid=intval(date("i"));
if ($nowid==0) $nowid=60;
if($nowid-$notify_id>1 || $nowid-$notify_id<0) {
	echo "false";
	exit();
}

//判断数据库中是否有这次通知的订单
$sql="select * from orderlist where trsno='".$out_trade_no."'";
$result=mysql_query($sql);
$row=mysql_fetch_array($result);
if(mysql_num_rows($result)<=0){
	echo "false";
	exit();
}else{
	//判断是否已经转账
	foreach ($row as $val){
		if ($row["states"]!="Y" || $row["isout"]!="Y"){
			echo "false";
			exit();
		}else if ($row["states"]=="Y" && $row["isout"]=="Y"){
			echo "true";
			exit();
		}else{
			echo "false";
			exit();
		}	
	}
}
mysql_close();
?>